import javax.swing.JOptionPane;
class DivideByZeroException extends ArithmeticException{
      // ĬϴϢĹ캯
      public DivideByZeroException() {
              super( " Attempted to divide by zero." );
      }
     //ָϢĹ캯
     public DivideByZeroException( String message ) {
           super( message );
     }
}
public class DivideByZeroTest {
    	public static void main(String []args){
		String firstnumber1,secondnumber2;
		int number1, number2;
   		double result;
                firstnumber1=JOptionPane.showInputDialog("Enter first integer");
   		secondnumber2=JOptionPane.showInputDialog("Enter second integer");
		try{
			number1 = Integer.parseInt(firstnumber1);
			number2 = Integer.parseInt(secondnumber2);
			result = quotient( number1, number2 );
             		JOptionPane.showMessageDialog(null, 
				"The  result is "+ result, 
				"Results ",JOptionPane.PLAIN_MESSAGE);
	   	} catch ( NumberFormatException numberFormatException ) {
         		JOptionPane.showMessageDialog( null,
            			"You must enter two integers",
            			"Invalid Number Format",
            			JOptionPane.ERROR_MESSAGE );
      		} catch ( ArithmeticException arithmeticException ) {
         		JOptionPane.showMessageDialog( null, 
            			arithmeticException.toString(),
            			"Arithmetic Exception",
            			JOptionPane.ERROR_MESSAGE );
      		}
	}
     public static double quotient( int numerator, int denominator )throws DivideByZeroException {
     	         if ( denominator == 0 )
                         throw new DivideByZeroException();
     	          return ( double ) numerator / denominator;
   	}	
}
